//
// Created by wwl on 2021/11/28.
//
#include <stdio.h>

void fun(int *a, int n, int *odd, int *even);

#define N 20



void main2() {
    int a[N] = {1, 9, 2, 3, 11, 6}, i, n = 6,odd,even;
    printf("The original data is:\n");
    for (i = 0; i < n; i++) {
        printf("%5d", *(a + i));
    }

    printf("\n\n");
    fun(a, n, &odd, &even);
    printf("\n\n");
    printf("The sum of odd numbers:%d\n", odd);
    printf("The sum of even number:%d\n", even);
}

void fun(int *p, int n, int *odd, int *even) {
    *odd = 0,*even = 0;
    for (int i = 0; i < n; ++i) {
        if (*(p + i) % 2 == 0) {
            *odd += *(p + i);
        } else {
            *even += *(p + i);
        }
    }


}

